module fv_calc_tb;
    
    localparam NUM_CONTRACTS = 3;
    logic clk_net;
    logic rst_n;

    logic [31:0] royal_gala_bidprice;
    logic [31:0] royal_gala_askprice;
    logic [7:0]  royal_gala_bidvolume;
    logic [7:0]  royal_gala_askvolume;
    logic [31:0] rels       [NUM_CONTRACTS];
    logic        fv_recalc_trigger;

    logic [31:0] fv_all     [NUM_CONTRACTS];

    fv_calc UUT ( .* );

    // Initialise clock
    initial clk_net = 0;
    always #5 clk_net = ~clk_net;

    initial begin
        $dumpfile("fv_calc_tb.vcd");
        $dumpvars(0,UUT);
        $dumpvars(0, UUT.fv_all[0]);
        $dumpvars(0, UUT.fv_all[1]);
        $dumpvars(0, UUT.fv_all[2]);

        rst_n = 0;
        fv_recalc_trigger = 0;
        royal_gala_bidprice = 0;
        royal_gala_askprice = 0;
        royal_gala_bidvolume = 0;
        royal_gala_askvolume = 0;

        // Assume the rels are Granny Smith +25, Fuji +10
        rels[0] = 0;
        rels[1] = 25;
        rels[2] = 10;

        #10 rst_n = 1;
        // Set the new FV
        #10
        royal_gala_bidvolume = 13;
        royal_gala_bidprice =  2500;
        royal_gala_askvolume = 3;
        royal_gala_askprice = 2505;
        fv_recalc_trigger = 1;

        #10 fv_recalc_trigger = 0;
        #50;
        
        // Test negative logic reset
        #20 rst_n = 0;
        #10;
        
        $finish;
    end

endmodule